/**
 * @brief 温湿度计
 */
#pragma once

#include "BridgedDevice.h"

// 温度传感器
class TemperatureSensor final : public BridgedDevice {

public:
    static constexpr DeviceTypeId kDeviceTypeTemperatureSensor = 0x0302;
    explicit TemperatureSensor(const BasicInformation *node);

    [[nodiscard]] int16_t GetMeasuredValue() const;
    void SetMeasuredValue(int16_t measurement);

    Protocols::InteractionModel::Status ReadAttribute(
            ClusterId clusterId,
            AttributeId attributeId,
            uint8_t* buffer,
            uint16_t maxReadLength) override;

    ChipError OnReport(const DataBlock* block) override;
    ChipError OnReadAttributes() override;

private:
    int16_t mMeasurement;
};

// 湿度传感器
class HumiditySensor final : public BridgedDevice {
public:
    static constexpr DeviceTypeId kDeviceTypeHumiditySensor = 0x0307;
    explicit HumiditySensor(const BasicInformation* node);

    [[nodiscard]] int16_t GetMeasuredValue() const;
    void SetMeasuredValue(int16_t measurement);

    Protocols::InteractionModel::Status ReadAttribute(
            ClusterId clusterId,
            AttributeId attributeId,
            uint8_t* buffer,
            uint16_t maxReadLength) override;

    ChipError OnReport(const DataBlock* block) override;
    ChipError OnReadAttributes() override;

private:
    int16_t mMeasurement;
};

